import Layout from '@/layout/index.vue';
// const Layout = () => import("@/layout/index.vue");

export const REDIRECT_ROUTE =
  {
    name: 'RedirectTo',
    path: '/redirect',
    component: Layout,
    meta: {
      hidden: true
    },
    children: [
      {
        name: 'RedirectTo',
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index.vue'),
      },
    ],
  }

export const LOGIN_ROUTE = {
  name: 'LOGIN',
  path: '/login',
  component: () => import('@/views/login/index.vue'),
  meta: {
    title: '登录页',
    hidden: true
  },
}

export const NOT_FOUND_ROUTE = {
  name: 'NotFound',
  path: '/:path(.*)*',
  component: Layout,
  meta: {
    title: '404',
    hidden: true
  },
  children: [
    {
      path: '/:path(.*)*',
      name: 'NotFound',
      component: () => import('@/views/error-page/404.vue'),
      meta: {
        title: '404',
        hidden: true
      },

    },
  ],
}

export const ROOT_ROUTE = {
  path: '/',
  name: 'Root',
  redirect: '/dashboard',
  component: Layout,
  meta: {
    title: 'Root',
    hidden: true
  },
};

const modules = import.meta.globEager('./modules/**/*.ts');
const routeModuleList: any[] = [];

Object.keys(modules).forEach((key) => {
  const mod = modules[key].default || {};
  const modList = Array.isArray(mod) ? [...mod] : [mod];
  routeModuleList.push(...modList);
});

// Object.keys(modules).forEach((key) => {
//   routeModuleList.push(...modules[key].default)
// })

export const asyncRoutes = [...routeModuleList];
export const basicRoutes = [
  LOGIN_ROUTE,
  ROOT_ROUTE,
  REDIRECT_ROUTE,
  // NOT_FOUND_ROUTE,
];
